home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Pascal / Libraries / WASTE 1.1a4 / WASTE Headers / C Interfaces / WASTE.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-13  |  11.0 KB  |  334 lines  |  [TEXT/R*ch]

  1. /*
  2.  *    WASTE.h
  3.  *
  4.  *    C/C++ interface to the WASTE text engine
  5.  *
  6.  *    version 1.1a4 (November 1994)
  7.  *
  8.  *    Copyright (c) 1993-1994 Merzwaren
  9.  *    All Rights Reserved
  10.  * 
  11.  */
  12.  
  13. #ifndef _WASTE_
  14. #define _WASTE_
  15.  
  16. #ifndef __LONGCOORDINATES__
  17. #ifndef _LongCoords_
  18. #include "LongCoords.h"
  19. #endif
  20. #endif
  21.  
  22. #ifndef __TEXTEDIT__
  23. #include <TextEdit.h>
  24. #endif
  25.  
  26. #ifndef __DRAG__
  27. #include <Drag.h>
  28. #endif
  29.  
  30. /*    result codes */
  31.  
  32. enum {
  33.     weCantUndoErr                =    -9479,    /* undo buffer is clear */
  34.     weUnknownObjectTypeErr        =    -9478,    /* specified object type is not registered */
  35.     weObjectNotFoundErr            =    -9477
  36. };
  37.  
  38. /*    alignment styles */
  39.  
  40. enum {
  41.     weFlushLeft         =    -2,        /* flush left */
  42.     weFlushRight        =    -1,        /* flush right */
  43.     weFlushDefault        =     0,        /* flush according to system direction */
  44.     weCenter            =     1,        /* centered */
  45.     weJustify            =     2        /* fully justified */
  46. };
  47.  
  48. /*    values for the mode parameter in WESetStyle and WEContinuousStyle */
  49.  
  50. enum {
  51.     weDoFont            =    0x0001,
  52.     weDoFace            =    0x0002,
  53.     weDoSize            =    0x0004,
  54.     weDoColor            =    0x0008,
  55.     weDoAll                =    weDoFont + weDoFace + weDoSize + weDoColor,
  56.     weDoAddSize            =    0x0010,
  57.     weDoToggleFace        =    0x0020,
  58.     weDoReplaceFace        =    0x0040
  59. };
  60.  
  61. /*    values for the edge parameter in WEGetOffset etc. */
  62.  
  63. enum {
  64.     kLeadingEdge = -1,                /* point is on the leading edge of a glyph */
  65.     kTrailingEdge = 0,                /* point is on the trailing edge of a glyph */
  66.     kObjectEdge = 2                    /* point is in the middle of an embedded object */
  67. };
  68.  
  69. /*    values for WEFeatureFlag feature parameter */
  70.  
  71. enum {
  72.     weFAutoScroll        =    0,        /* automatically scroll the selection range into view */
  73.     weFOutlineHilite    =    2,        /* frame selection when deactivated */
  74.     weFUndo                =    6,        /* support WEUndo() */
  75.     weFIntCutAndPaste    =    7,        /* use intelligent cut-and-paste rules */
  76.     weFDragAndDrop        =    8,        /* support drag-and-drop text editing */
  77.     weFInhibitRecal        =    9,        /* don't recalculate line starts and don't redraw text */
  78.     weFUseTempMem        =    10,        /* use temporary memory for main data structures */
  79.     weFDrawOffscreen    =    11        /* draw text offscreen for smoother visual results */
  80. };
  81.  
  82. /*    values for WENew flags parameter */
  83.  
  84. enum {
  85.     weDoAutoScroll        =    1 << weFAutoScroll,
  86.     weDoOutlineHilite    =    1 << weFOutlineHilite,
  87.     weDoUndo            =    1 << weFUndo,
  88.     weDoIntCutAndPaste    =    1 << weFIntCutAndPaste,
  89.     weDoDragAndDrop        =    1 << weFDragAndDrop,
  90.     weDoInhibitRecal    =    1 << weFInhibitRecal,
  91.     weDoUseTempMem        =    1 << weFUseTempMem,
  92.     weDoDrawOffscreen    =    1 << weFDrawOffscreen
  93. };
  94.  
  95. /*    values for WEFeatureFlag action parameter */
  96.  
  97. enum {
  98.     weBitTest = -1,                /* return the current setting of the specified feature */
  99.     weBitClear,                    /* disables the specified feature */
  100.     weBitSet                    /* enables the specified feature */
  101. };
  102.  
  103. /*    selectors for WEGetInfo and WESetInfo */
  104.  
  105. enum {
  106.     weClickLoop            =    'clik',    /* click loop callback */
  107.     weCurrentDrag        =    'drag',    /* drag currently being tracked from WEClick() */
  108.     wePort                =    'port',    /* graphics port */
  109.     weRefCon            =    'refc',    /* reference constant for use by application */
  110.     weScrollProc        =    'scrl',    /* auto-scroll callback */
  111.     weText                =    'text',    /* text handle */
  112.     weTranslateDragHook =    'xdrg', /* drag translation callback */
  113.     weTSMDocumentID        =    'tsmd',    /* Text Services Manager document ID */
  114.     weTSMPreUpdate        =    'pre ',    /* Text Services Manager pre-update callback */
  115.     weTSMPostUpdate        =    'post'    /* Text Services Manager post-update callback */
  116. };
  117.  
  118. /*    values for WEInstallObjectHandler handlerSelector parameter */
  119.  
  120. enum {
  121.     weNewHandler        =    'new ',        /* new handler */
  122.     weDisposeHandler    =    'free',        /* dispose handler */
  123.     weDrawHandler        =    'draw',        /* draw handler */
  124.     weClickHandler        =    'clik',        /* click handler */
  125.     weCursorHandler        =    'curs'        /* reserved for future use */
  126. };
  127.  
  128. /*    action kinds */
  129.  
  130. enum {
  131.     weAKNone            =    0,        /* null action */
  132.     weAKUnspecified        =    1,        /* action of unspecified nature */
  133.     weAKTyping            =    2,        /* some text has been typed in */
  134.     weAKCut                =    3,        /* the selection range has been cut */
  135.     weAKPaste            =    4,        /* something has been pasted */
  136.     weAKClear            =    5,        /* the selection range has been deleted */
  137.     weAKDrag            =    6,        /* drag and drop operation */
  138.     weAKSetStyle        =    7        /* some style has been applied to a text range */
  139. };
  140.  
  141. typedef Handle WEHandle;
  142. typedef Handle WEObjectReference;
  143. typedef Handle WESoupHandle;
  144. typedef short WEActionKind;
  145.  
  146. typedef struct WERunInfo {
  147.     long                 runStart;    /* byte offset to first character of style run */
  148.     long                 runEnd;        /* byte offset past last character of style run */
  149.     short                 runHeight;    /* line height (ascent + descent + leading) */
  150.     short                 runAscent;    /* font ascent */
  151.     TextStyle             runStyle;    /* text attributes */
  152.     WEObjectReference    runObject;    /* either NULL or reference to embedded object */
  153. } WERunInfo;
  154.  
  155. /*    callback prototypes */
  156.  
  157. typedef pascal Boolean (*WEClickLoopProcPtr)(WEHandle hWE);
  158. typedef pascal void (*WEScrollProcPtr)(WEHandle hWE);
  159. typedef pascal void (*WETSMPreUpdateProcPtr)(WEHandle hWE);
  160. typedef pascal void (*WETSMPostUpdateProcPtr)(WEHandle hWE,
  161.         long fixLength, long inputAreaStart, long inputAreaEnd,
  162.         long pinRangeStart, long pinRangeEnd);
  163. typedef pascal OSErr (*WETranslateDragProcPtr)(DragReference theDrag,
  164.         ItemReference theItem, FlavorType requestedType, Handle putDataHere);
  165. typedef Pascal OSErr (*WENewObjectProcPtr)(Point *defaultObjectSize,
  166.         WEObjectReference objectRef);
  167. typedef pascal OSErr (*WEDisposeObjectProcPtr)(WEObjectReference objectRef);
  168. typedef pascal OSErr (*WEDrawObjectProcPtr)(const Rect *destRect,
  169.         WEObjectReference objectRef);
  170.  
  171. /*    WASTE public calls */
  172.  
  173. #ifdef __cplusplus
  174. extern "C" {
  175. #endif
  176.  
  177. /*    creation and destruction */
  178.  
  179. pascal OSErr WENew(const LongRect *destRect, const LongRect *viewRect, short flags, WEHandle *hWE);
  180. pascal void WEDispose(WEHandle hWE);
  181.  
  182. /*    getting variables */
  183.  
  184. pascal Handle WEGetText(WEHandle hWE);
  185. pascal short WEGetChar(long offset, WEHandle hWE);
  186. pascal long WEGetTextLength(WEHandle hWE);
  187. pascal long WECountLines(WEHandle hWE);
  188. pascal long WEGetHeight(long startLine, long endLine, WEHandle hWE);
  189. pascal void WEGetSelection(long *selStart, long *selEnd, WEHandle hWE);
  190. pascal void WEGetDestRect(LongRect *destRect, WEHandle hWE);
  191. pascal void WEGetViewRect(LongRect *viewRect, WEHandle hWE);
  192. pascal Boolean WEIsActive(WEHandle hWE);
  193.  
  194. /*    setting variables */
  195.  
  196. pascal void WESetSelection(long selStart, long selEnd, WEHandle hWE);
  197. pascal void WESetDestRect(const LongRect *destRect, WEHandle hWE);
  198. pascal void WESetViewRect(const LongRect *viewRect, WEHandle hWE);
  199.  
  200. /*    accessing style run information */
  201.  
  202. pascal Boolean WEContinuousStyle(short *mode, TextStyle *ts, WEHandle hWE);
  203. pascal void WEGetRunInfo(long offset, WERunInfo *runInfo, WEHandle hWE);
  204.  
  205. /*    converting byte offsets to screen position and vice versa */
  206.  
  207. pascal long WEGetOffset(const LongPt *thePoint, char *edge, WEHandle hWE);
  208. pascal void WEGetPoint(long offset, LongPt *thePoint, short *lineHeight, WEHandle hWE);
  209.  
  210. /*    finding words and lines */
  211.  
  212. pascal void WEFindWord(long offset, char edge, long *wordStart, long *wordEnd, WEHandle hWE);
  213. pascal void WEFindLine(long offset, char edge, long *lineStart, long *lineEnd, WEHandle hWE);
  214.  
  215. /*    making a copy of a text range */
  216.  
  217. pascal OSErr WECopyRange(long rangeStart, long rangeEnd, Handle hText, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
  218.  
  219. /*    getting and setting the alignment style */
  220.  
  221. pascal char WEGetAlignment(WEHandle hWE);
  222. pascal void WESetAlignment(char alignment, WEHandle hWE);
  223.  
  224. /*    recalculating line breaks, drawing and scrolling */
  225.  
  226. pascal OSErr WECalText(WEHandle hWE);
  227. pascal void WEUpdate(RgnHandle updateRgn, WEHandle hWE);
  228. pascal void WEScroll(long hOffset, long vOffset, WEHandle hWE);
  229. pascal void WESelView(WEHandle hWE);
  230.  
  231. /*    handling activate / deactivate events */
  232.  
  233. pascal void WEActivate(WEHandle hWE);
  234. pascal void WEDeactivate(WEHandle hWE);
  235.  
  236. /*     handling key-down events */
  237.  
  238. pascal void WEKey(short key, short modifiers, WEHandle hWE);
  239.  
  240. /*    handling mouse-down events and mouse tracking */
  241.  
  242. pascal void WEClick(Point hitPt, short modifiers, long clickTime, WEHandle hWE);
  243.  
  244. /*    adjusting the cursor shape */
  245.  
  246. pascal Boolean WEAdjustCursor(Point mouseLoc, RgnHandle mouseRgn, WEHandle hWE);
  247.  
  248. /*    blinking the caret */
  249.  
  250. pascal void WEIdle(long *maxSleep, WEHandle hWE);
  251.  
  252. /*    modifying the text and the styles */
  253.  
  254. pascal OSErr WEInsert(const void *pText, long textLength, StScrpHandle hStyles, WESoupHandle hSoup, WEHandle hWE);
  255. pascal OSErr WEDelete(WEHandle hWE);
  256. pascal OSErr WESetStyle(short mode, const TextStyle *ts, WEHandle hWE);
  257. pascal OSErr WEUseStyleScrap(StScrpHandle hStyles, WEHandle hWE);
  258. pascal OSErr WEUseText(Handle hText, WEHandle hWE);
  259.  
  260. /*    undo */
  261.  
  262. pascal OSErr WEUndo(WEHandle hWE);
  263. pascal void WEClearUndo(WEHandle hWE);
  264. pascal WEActionKind WEGetUndoInfo(Boolean *redoFlag, WEHandle hWE);
  265. pascal Boolean WEIsTyping(WEHandle hWE);
  266.  
  267. /*    keeping track of changes */
  268.  
  269. pascal long WEGetModCount(WEHandle hWE);
  270. pascal void WEResetModCount(WEHandle hWE);
  271.  
  272. /*    embedded objects */
  273.  
  274. pascal OSErr WEInstallObjectHandler(OSType objectType, OSType handlerSelector, ProcPtr handler);
  275. pascal OSErr WEInsertObject(OSType objectType, Handle objectDataHandle, Point objectSize, WEHandle hWE);
  276. pascal OSErr WEGetSelectedObject(WEObjectReference *objectRef, WEHandle hWE);
  277. pascal long WEFindNextObject(long offset, WEObjectReference *objectRef, WEHandle hWE);
  278.  
  279. /*    accessing embedded object attributes */
  280.  
  281. pascal OSType WEGetObjectType(WEObjectReference objectRef);
  282. pascal Handle WEGetObjectDataHandle(WEObjectReference objectRef);
  283. pascal Point WEGetObjectSize(WEObjectReference objectRef);
  284. pascal WEHandle WEGetObjectOwner(WEObjectReference objectRef);
  285. pascal long WEGetObjectRefCon(WEObjectReference objectRef);
  286. pascal void WESetObjectRefCon(WEObjectReference objectRef, long refCon);
  287.  
  288. /*    clipboard operations */
  289.  
  290. pascal OSErr WECut(WEHandle hWE);
  291. pascal OSErr WECopy(WEHandle hWE);
  292. pascal OSErr WEPaste(WEHandle hWE);
  293. pascal Boolean WECanPaste(void);
  294.  
  295. /*    Drag Manager support */
  296.  
  297. pascal RgnHandle WEGetHiliteRgn(long rangeStart, long rangeEnd, WEHandle hWE);
  298. pascal OSErr WETrackDrag(DragTrackingMessage message, DragReference drag, WEHandle hWE);
  299. pascal OSErr WEReceiveDrag(DragReference drag, WEHandle hWE);
  300. pascal Boolean WECanAcceptDrag(DragReference drag, WEHandle hWE);
  301. pascal Boolean WEDraggedToTrash(DragReference drag);
  302.  
  303. /*    Script Manager utilities */
  304.  
  305. pascal short WECharByte(long offset, WEHandle hWE);
  306. pascal short WECharType(long offset, WEHandle hWE);
  307.  
  308. /*    Text Services Manager support */
  309.  
  310. pascal OSErr WEInstallTSMHandlers(void);
  311. pascal void WEStopInlineSession(WEHandle hWE);
  312.  
  313. /*    additional features */
  314.  
  315. pascal short WEFeatureFlag(short feature, short action, WEHandle hWE);
  316. pascal OSErr WEGetInfo(OSType selector, void *info, WEHandle hWE);
  317. pascal OSErr WESetInfo(OSType selector, const void *info, WEHandle hWE);
  318.  
  319. /*    long coordinate utilities */
  320.  
  321. pascal void WELongPointToPoint(const LongPt *lp, Point *p);
  322. pascal void WEPointToLongPoint(Point p, LongPt *lp);
  323. pascal void WESetLongRect(LongRect *lr, long left, long top, long right, long bottom);
  324. pascal void WELongRectToRect(const LongRect *lr, Rect *r);
  325. pascal void WERectToLongRect(const Rect *r, LongRect *lr);
  326. pascal void WEOffsetLongRect(LongRect *lr, long hOffset, long vOffset);
  327. pascal Boolean WELongPointInLongRect(const LongPt *lp, const LongRect *lr);
  328.  
  329. #ifdef __cplusplus
  330. }
  331. #endif
  332.  
  333. #endif
  334.